import Vue from 'vue'
import Vuex from 'vuex'
import api from '../api'
Vue.use(Vuex)

const actions = {
  getSong(context,id) {
    api.getPlayer({
      id:id,
    }).then(res => {
      context.commit('playSong',res)
      // console.log(res)
    });
  }
};

const mutations = {
  playSong(state,res) {
    state.songUrl = res.data[0].url    
  }
};

const state = {
  songUrl:null,
  songCover:null,
  songLriycs:null,
  songName:null,
  currentTime:0,
}

export default new Vuex.Store({
  actions,
  mutations,
  state,
})